package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectPlanDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.dto.UpdateNursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 护理项目Controller类
 */
@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理")
public class NursingProjectController {
    @Autowired
    private NursingProjectService nursingProjectService;

    @GetMapping
    @ApiOperation("分页查询护理项目列表")
    public ResponseResult<PageResponse<NursingProjectVo>> getByPage(NursingProjectDto dto) {
        PageResponse<NursingProjectVo> nursingProjectPageInfo = nursingProjectService.getByPage(dto);
        return ResponseResult.success(nursingProjectPageInfo);
    }

    @PostMapping
    @ApiOperation("新增护理项目列表")
    public ResponseResult insert(@RequestBody NursingProjectPlanDto dto) {
        nursingProjectService.insert(dto);
        return ResponseResult.success();
    }

    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> selectById(@PathVariable("id") Long id) {
        NursingProjectVo vo = nursingProjectService.selectById(id);
        return ResponseResult.success(vo);
    }

    @PutMapping
    public ResponseResult update(@RequestBody UpdateNursingProjectDto dto) {
        nursingProjectService.update(dto);
        return ResponseResult.success();
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        nursingProjectService.delete(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    public ResponseResult disAble(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        nursingProjectService.disAble(id,status);
        return ResponseResult.success();
    }
}